package com.zhuojy.equity.mall.admin.service;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.TPosition;
import com.zhuojy.equity.mall.admin.common.entity.TUser;
import com.zhuojy.equity.mall.admin.dal.mapper.DemoMapper;
import com.zhuojy.equity.mall.admin.dal.mapper.TPositionMapper;
import com.zhuojy.equity.mall.admin.manager.DemoManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class DemoService extends ServiceImpl<DemoMapper, TUser> {
    private final DemoManager demoManager;
    @Autowired
    private TPositionMapper tPositionMapper;
    public void findAll() {
//        demoManager.findAll();
        List<TUser> tUsers = this.baseMapper.selectList(null);
        tUsers.forEach(System.out::println);
    }

    /**
     * @description:审核员（抄送人）列表查询、不是当前登录人
     * @author: lyl
     * @date: 2024/3/20 10:57
     * @param: id
     * @return: java.util.List<com.zhuojy.equity.mall.admin.common.entity.TUser>
     **/
    public List<TUser> findTUserList(Long id) {
        QueryWrapper<TUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne("id",id);
        return this.baseMapper.selectList(queryWrapper);
//        demoManager.findAll();
    }
    //审批审批人
    public TUser findUserAndAuditById(Long id,Integer sponsorId) {
        return this.baseMapper.findUserAndAuditById(id,sponsorId);
    }
    //审批抄送人
    public TUser findUserAndAuditById2(Long id, Integer sponsorId) {
        return this.baseMapper.findUserAndAuditById2(id,sponsorId);
    }

    public TUser findOneUser(Long id) {
        TUser tUser = this.baseMapper.selectOne(new LambdaQueryWrapper<TUser>().eq(TUser::getId, id));
        tUser.setTPosition(tPositionMapper.selectOne(new LambdaQueryWrapper<TPosition>().eq(TPosition::getId, tUser.getPositionId())));
        return tUser;
    }
    public TUser findUserAndAuditById3(Long id, int carUserId) {
        return this.baseMapper.findUserAndAuditById3(id,carUserId);
    }

    public TUser findUserAndAuditById4(Long id,Integer carUserId) {
        return this.baseMapper.findUserAndAuditById4(id,carUserId);
    }
    //报销抄送人
    public TUser findUserAndExpenseById2(Long id, Integer sponsorId) {
        return this.baseMapper.findUserAndExpenseById2(id,sponsorId);
    }
    //报销审批人
    public TUser findUserAndExpenseById(Long id, Integer sponsorId) {
        return this.baseMapper.findUserAndExpenseById(id,sponsorId);
    }
}

